package com.bw.servlet;

import com.bw.dao.PhoneDao;
import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/***************************
 FileAction:

 CreateTime:2022-05-11 9:59
 Author:Aaking-aline
 ****************************/
@WebServlet("/DeletePhoneServlet")
public class DeletePhoneServlet extends HttpServlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	@SneakyThrows
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// getParameter  拿的是什么数据  getAttribute  拿的是什么数据 拿的是request对象里面的数据
		String id = request.getParameter("id");   // 1,2,3

		new PhoneDao().deletePhone(id);

		response.sendRedirect("message.jsp");
	}
}
